package functional.closure;

import java.util.function.IntSupplier;

/**
 * @ClassName Closure4
 * @PackageName functional.closure
 * @projectName myThread
 * @Description 
 * @Author games
 * @Date 2025/8/27 下午1:33
 * @Version 1.0
 */

public class Closure6 {

    IntSupplier makeFun(int x) {
        /**
         * 在闭包中使用 final 关键字提前修饰变量 x 和 i
         */
        int i = 0;
        i++;
        x++;
        final int iFinal = i;
        final int xFinal = x;
        return () -> xFinal + iFinal;
    }
}